<html>
<head>
    <meta charset = "utf-8" />

</head>

<body>

<?php

require_once 'Konekcija.php';

require_once 'Student.php';

$sql = "select * from student";
if(!$query = $mysqli->query($sql))
    echo "Greska pri izvodjenju upita" . mysql_error();

$studenti = array();


while($row = $query->fetch_object()){
    $student = new Student($row->indeks, $row->ime, $row->prezime, $row->smer, $row->datum_rodjenja);
    array_push($studenti, $student);
}

echo json_encode($studenti);

echo "<table border='1'>";
foreach($studenti as $x){

    echo "<tr>";

    echo "<td>";
    echo $x->getIme();
    echo "</td>";

    echo "<td>";
    echo $x->getPrezime();
    echo "</td>";

    echo "<td>";
    echo $x->getIndeks();
    echo "</td>";

    echo "</tr>";
}
echo "</table>";

echo "<ul>";
foreach ($studenti as $x){
    echo json_encode($x->expose());
}
echo "</ul>";



?>

</body>

</html>